﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using XCommunity.Frames;
using System.Reflection;

namespace XCommunity.Views
{


  /// <summary>
  /// 定义视图对象的基类，视图是表示数据表现形式的对象，可以被序列化和传输，由Presenter来负责呈现。
  /// </summary>
  public abstract class ViewObject
  {


    protected ViewObject( ViewService service )
    {
      _service = service;
    }


    public abstract object BaseObject
    {
      get;
    }


    private ViewService _service;
    public ViewService Service
    {
      get { return _service; }
    }




    public virtual object GetValue( string propertyName )
    {
      var property = GetType().GetProperty( propertyName );

      if ( property != null )
        return Service.GetValue( this, property );

      return Service.GetValue( this, propertyName );
    }



    public object this[string propertyName]
    {
      get { return GetValue( propertyName ); }
    }

  }
}
